home *** CD-ROM | disk | FTP | other *** search
/ El Mac 8 / El Mac 8.iso / Shareware / Applications / 4th Artificial Life / Manual < prev   
Encoding:
Text File  |  1996-03-15  |  45.9 KB  |  776 lines  |  [TEXT/MSWD]

  1. ***************************************************************************
  2. ************************** 4th Artifical Life ******************************
  3. ***************************************************************************
  4.  
  5. This package presents three programs that demonstrate some very interesting concepts: chaos in rules (Life), evolution (Animal Farm)
  6. and learning in neural networks (ChaseNet):
  7.  
  8. 1) 'LIFE', the famous AUTOMATIC BOARD GAME, that calculates
  9.     new populations with 3 rules. Produces interesting 'swerms'.
  10. 2) 'ANIMAL FARM', a GENETIC cellular AUTOMATA algoritm, that     demonstrates concepts like evolution and even biosystems.
  11.     Witness evolving fauna eating too much flora and disturbing balance.
  12. 3) 'CHASENET', a small NEURAL NET that drives a very simplistic 
  13.     'virtual robotcar'. It uses 'hill climbing' to improve chasing an object. 
  14. >> These three programs can be EXECUTED by dropping them on 'Forth' <<
  15.  
  16. *The file Extended.4th is a small extension that is used by these files.
  17. *The Forth programming language is explained in short in the Manual
  18.   and all the commands are described in the Glossary (see below)
  19.  
  20. ***************************************************************************
  21. Animal Farm
  22.  
  23. Animal farm presents a small 'world' on the display,
  24. it is an 20*20 array, so that means a 400 places to stay
  25. for the creatures that are going to live in that world.
  26. Each place receives some free energy (like from the SUN)
  27. and a creature on that place can collect that energy.
  28.  
  29. Species & Energy:
  30. Time begins with just one member of the specie 'A'.
  31. The specie name is calculated from it's features:
  32. -defense force (D)
  33. -attack force (A)
  34. -speed  (S)
  35. Specie name: A+4*D+10*S  ->  0-25  ->  A-Z
  36. So the higher the ASCI-code the more 'powerful' the specie!
  37. Of course having features costs energy (E):
  38. each calculation step: E -> E+SUN-(A+D+2S)
  39.  
  40. Moving and Reproducing:
  41. When a specie CAN move, it moves randomly. But every place it 
  42. decides to take over it has take conquer the creature that's already there.
  43. When his attack is more powerful than the defense of his opponent
  44. he takes that place and the life and energy of his opponent (if not: v.v.)
  45. The same thing occurs when a creature decides to divide itself (energy is 
  46. splitted). It's offspring (which might be mutated) has to conquer a place to 
  47. live.
  48.  
  49. Notice that after a while species occur which could not live without the
  50. lower species: a real bio system!
  51.  
  52. [Animal Farm concept: Mervyn@xs4all.nl 1995]
  53.  
  54. ***************************************************************************
  55. Life
  56.  
  57. Life explains what is does as it is executed
  58.  
  59. [Life concept: Conway 1970]
  60.  
  61. ***************************************************************************
  62. ChaseNet
  63.  
  64. ChaseNet explains what it does as it is executed.
  65.  
  66. PS: the values that are constantly changing are the factors that the
  67. 0/1 at the inputs are multiplied with. The threshold is 10. So when an
  68. input is high (1) and the factor is greater than 10, the next neuron is activated (just follow the lines on the screen).
  69.  
  70. [ChaseNet concept: Mervyn@xs4all.nl 1995]
  71.  
  72. ***************************************************************************
  73. ************************ FORTH Manual ***********************************
  74. ***************************************************************************
  75.  
  76. Creating your own clickable Mac applications is quite easy. 
  77. Pocket Forth (by Chris Heilman) is a powerful tool to do just that. 
  78. *Create your source code using your favorite word processor (plain text)
  79. *Drop the document on Pocket Forth
  80.  Pocket Forth compiles the new word definitions and interprets direct
  81.  commands in the document (e.g. 'run this program').
  82. *If the program is debugged and does the job fine, drop it onto a COPY
  83.  of Forth, and make it a 'turnkey' by saving it into the 'standard library'
  84.  (of that copy) and tell it to always start with that program. It then is
  85.  a clickable application! (Forth is only 18K small, so who cares!)
  86.  
  87. ***************************************************************************
  88. FORTH PROGRAMMING in just 6 small steps
  89.  
  90. << This is NOT a manual that describes all the possibilities
  91.     of FORTH, it's meant to get you going. I learned FORTH during the 
  92.     last14 days, so I can't tell you all the ins and outs, but I hope this 
  93.     will prove to you that FORTH is simple,  but powerful!                  >>
  94.  
  95. ***************************************************************************
  96. 1 THE STACK
  97.  
  98. The most important item to understand when using Forth is the STACK.
  99. The stack is a piece of memory that works like a tube with only one
  100. open end: YOU CAN ONLY GET OUT WHAT YOU PUT IN LAST!!
  101.  
  102. The only thing you can put in are 16 bit values. Since one bit is used as
  103. a sign bit, that leaves 15 bits too define the value: 2^15=32768
  104. This means you can insert INTEGERS in the RANGE -32767 to 32767.
  105. (32 bit numbers and floats are also possible, but use special commands)
  106.  
  107. The stack is used for all calculations, that's why it is 'post-fixed'.
  108. Each value (or address) that is typed or present in a program, is
  109. put on the stack. Standard commands or self defined 'words' always
  110. use values that have to be ALREADY ON THE STACK. They take them off, and
  111. instead put a result (if there is any) on the stack.
  112.  
  113. For example:     2 3 + .        
  114. This puts 2 on stack, 3 on stack, runs the standard word "+", which
  115. always takes and adds the two values on the top of the stack and leaves the
  116. result on the stack. The command "." takes the value of the top of the stack
  117. and puts it onto the screen, so the value 5 appears on screen as a result of these instructions.
  118. It could have been left on the stack to perform another calculation:
  119.             2 3 + 6 - .        puts the value -1 on the screen
  120.         or    2 3 6 + - .        puts the value -7 on the screen!
  121.  
  122. The stack is quite 'deep', but not infinite, so ALWAYS MAKE SURE THAT WHAT GOES ON THE STACK, GOES OFF AGAIN (SOON OR LATE)!
  123. If this is not done, it will result in errors (stack overflow or underflow) and stop the program, especially when using loops!
  124.  
  125. ***************************************************************************
  126. 2 VARIABLES
  127.  
  128. Of course not everything is stored 'on the stack'. But also storing values
  129. in normal memory addresses is done via the stack.
  130.             variable AD
  131. This command allocates space in the memory for a value on the address AD.
  132. AD is now the same as the address that can be used. It IS that address, a value, just like 6770 is! So just type:
  133.             AD .
  134. to check which address. Not that that's interesting, because that value is just the address of a piece of memory we can use!
  135. The commands @ and ! can be used to read and write on that address:
  136.             AD            puts the allocated address on stack 
  137.             AD @        puts the content of address AD on stack
  138.             AD @ .        puts the content of address AD on screen
  139.             100 AD !        puts 100 in address AD
  140.             AD 100 !        puts address AD in address 100: ILLEGAL!
  141. NB: SO "@" MEANS READ AND "!" MEANS WRITE!
  142.  
  143. ***************************************************************************
  144. 3 ARRAYS
  145.  
  146. Sometimes it is necessary to store or read a whole list of values.
  147. This could be done by defining just as many variables, but it is usually done using an array.
  148.             variable AD allot 10
  149. This command allocates not just room for one value, but for FIVE values.
  150. NB: ONLY EVEN ADDRESSES ARE USED e.g.:
  151.             AD 2 + @        puts the content of address AD+2 on stack
  152.             10 AD 10 + !    puts 10 in address AD+10
  153.             10 10 AD + !    (idem!)
  154.  
  155.  
  156. ***************************************************************************
  157. 4 LOOPS
  158.  
  159. A loop can be used to fill an array with data:
  160.             10 0 Do   200 I 2 * +   AD I + !    2 +Loop
  161. This creates a loop between "Do" and "Loop". 
  162. It 'loops' 5 times: 0 to 10, step 2
  163. "I" puts the 'index' of the loop on the stack (0 2 4 6 8)
  164. It stores (!) 200+2*I in the address AD+0 AD+2 AD+4 AD+6 and AD+8.
  165. So afterwards:    AD @        puts 200 on stack
  166.             AD 2 + @        puts 204 on stack        
  167.             AD 4 + @         puts 208 on stack
  168.             AD 6 + @         puts 212 on stack
  169.             AD 8 + @         puts 216 on stack
  170.  
  171. The line:        Begin ... Again
  172. Creates an endless loop between "Begin" and "Again".
  173.  
  174.  
  175. ***************************************************************************
  176. 5 CONDITIONAL LOOPS AND BRANCHING
  177.  
  178. Not all loops are defined or endless. Sometimes something has to be
  179. done UNTIL e.g. a key is pressed. Or only IF a key is pressed, or a certain
  180. value is reached!
  181. Conditions can be tested and the result will set a 'FLAG' to true or false.
  182.             2 3 =        This will set the FLAG to false
  183.             2 3 * 6 =        This will set the FLAG to true
  184. AFTER the FLAG is set it can be used to break or maintain a loop, or to
  185. execute a conditional set of instructions:
  186.             (flag) if ... then        ... is executed if the flag is true
  187.             (flag) if . else ... then    ... is executed if the flag is false
  188.             BEGIN …  (flag) WHILE … REPEAT
  189.             BEGIN …  (flag) UNTIL
  190.  
  191. ***************************************************************************
  192. 6 USING and CREATING "WORDS": PROGRAMMING
  193.  
  194. These are frequently used STANDARD COMMANDS or "WORDS":
  195.  
  196. : WORD ... ;        compile ... as new subroutine called WORD            
  197. / * - +         divide, times, minus, sum
  198. =   <   >        checks relation upper two stack values, sets flag 
  199. .            displays top value on stack (removes value off stack)
  200. ." text"        display textstring (start with space!)
  201. DUP            duplicates stack (to evoid destruction)
  202. DROP        destroy top of stack
  203. SWAP        exchange upper two stck values
  204. VARIABLE X    claims use of memory address to be called X
  205. 4 ALLOT        claims 4 more bytes beyond X (used after variable ...)
  206. 2 X !            puts 2 in address X
  207. 2 X +!        adds 2 to the content of address X
  208. 8 X 2 + !        puts 8 in address X+2 (array)
  209. X @            puts content of address X on stack
  210. KEY            puts ASCII code of typed key on stack (waits)
  211. PAGE        clears screen, cursor to upper left
  212. @MOUSE        puts mouse coordinates on stack
  213. ?BUTTON        sets flag true if mousebutton clicked
  214. ?TERMINAL    sets flag true if key pressed
  215. CR            carriage return
  216. !PEN            moves cursor/drawing pen to 2 upper stack coordinates
  217. @PEN        puts pen coordinates on stack
  218. -TO            draws line to 2 upper stack coordinates
  219. 13 emit        display character 13 of ASCII table
  220. BEEP            sounds default beep
  221. QUIT        exits program, return to interpreter
  222. S 10 EXPECT    stores 10 characters starting at address S
  223. S 10 TYPE        displays 10 characters starting at address S
  224. PMODE        uses stack to set drawing mode
  225. --> Drive:Path:Name    loads and interprets Forth file (see example below)
  226.  
  227. NB (conditional) loops and branches are described in §4 and 5!
  228. NB Check the Glossary and download the original Pocket Forth-package 
  229. for more info on Forth, Apple Events and the toolbox.
  230.  
  231. Defined in Extended.4th:
  232. I                    puts index of loop on stack (J if nested)
  233. -9 DABS                returns absolute value (puts 9 on stack)
  234. RANDOMIZE            randomize using the clock
  235. 5 RANDOM            puts random integer between 0-4 on stack
  236. create "name" , " string"    puts string on address "name" (WINDOW)
  237. "name" WTITLE            uses "string" as window title
  238. 200 100 WSIZE            sizes window 200x100 pixels
  239. FCOLOR                use:     white, black, blue, green, red, cyan, 
  240. BCOLOR                magenta, yellow  e.g. "blue FCOLOR"
  241.                     F=foreground(pen)  B=background(window)
  242. !FONT                 ( n -- )    set font
  243. !FSIZE                 ( n -- )     set size
  244. !FACE                 ( face -- )    set style
  245. !FMODE                 ( mode -- ) set mode
  246. SYSFONT                 use System font
  247. MONACO9             use Normal font
  248.  
  249.  
  250. NEW WORDS can be CREATED by using ":" and ";"
  251.             : TEST ." test" ;
  252. This instruction compiles a subroutine TEST, that can be called from the
  253. interpreter, or be used in another subroutine e.g.:
  254.             : GO Do TEST ?terminal Until ;
  255. GO displays "test test test ....." until a key is pressed.
  256.  
  257. NB:     -Forth is not case sensitive: DO is the same as Do or do.
  258.     -a SPACE or TAB has to divide ALL instructions (remember that
  259.       also values and things like "+" or ":" and ";" are instructions!)
  260.  
  261. We will now take a look at LIFE to demonstrate how an application is made:
  262. This is my file "Documenten:Development:Forth:Life.4th"
  263. (Comment is found after "\ ")
  264.  
  265. \ ****** LIFE  in  FORTH  by  MERVYN@xs4all.nl *******
  266. --> Documenten:Development:Forth:Extended.4th
  267. \ this adds the new words in Extended.4th to the language!
  268. \ this file can be altered to create your own customized Forth version
  269. variable FIELD 2600 allot  variable FIELD2 2600 allot  
  270. \ this allocates twee arrays for 1300 (remember?) integers
  271. variable PLACE variable PL variable X variable Y  
  272. create "TITLE" ," Life"  
  273. \ this puts the string Life on the address "TITLE"
  274.  
  275. : COPYFIELDS  2600 0 Do  I FIELD2 + @  I FIELD + !  2 +Loop ;
  276. \ a new word that copies the changed array FIELD2 to FIELD
  277.  
  278. : SETUP Begin  2480 80 Do  80 0 Do   
  279.     I J + FIELD2 + @  1 = if I 5 * J 80 - 6 / !PEN ." *" then 
  280.     \ this displays the array as a 2d field of stars (if field=1)
  281.     \ I is the second (nested) index, J the first!
  282.     2 +Loop  80 +Loop  key 
  283.     dup 28 = if PLACE @ 2 - PLACE ! then
  284.     dup 29 = if PLACE @ 2 + PLACE ! then
  285.     dup 30 = if PLACE @ 80 - PLACE ! then
  286.     dup 31 = if PLACE @ 80 + PLACE ! then
  287.     dup 32 = if  1 FIELD2 PLACE @ + !  then
  288.     \ this uses the cursor keys and space to set up a field
  289.            13 = Until ;
  290.  
  291. : INIT  FIELD2 2600 0 fill  COPYFIELDS 1400 PLACE !  
  292.     BLACK bcolor WHITE fcolor 500 310 wsize  "TITLE" wtitle page 
  293.     \ sets colors and sizes and names window, clears screen
  294.     CR CR 
  295.     ."       LIFE by Mervyn@xs4all.nl (programmed in Forth)" CR CR
  296.     ."       LIFE calculates new board populations using these rules:" CR
  297.     ."       -3 neighbours? -> Birth " CR
  298.     ."       -Less than 2 or more than 3 neighbours? -> Death" CR CR
  299.     ."       Press any key to toggle between <Field setup> and <Life>" CR
  300.     ."       (Use space/arrow keys to create a field)  " 
  301.     key drop page SETUP ; 
  302.  
  303. : MAINLOOP  2480 80 Do  80 0 Do  I J + FIELD + PL !    
  304.     PL @ 2 + @         PL @ 2 - @    
  305.     PL @ 78 + @        PL @ 78 - @ 
  306.     PL @ 80 + @        PL @ 80 - @     
  307.     PL @ 82 + @        PL @ 82 - @    
  308.     + + + + + + +  
  309.     \ puts the amount of neighbors on the stack
  310.     PL @ @ 
  311.     \ puts the content of the current PLace on the stack (0=empty / 1=*) 
  312.     0 = if 3 = if 1 I J + FIELD2 + !  I 5 * J 80 - 6 / !PEN ." *" then else
  313.     dup 2 < if 0 I J + FIELD2 + ! I 5 * J 80 - 6 / !PEN ."  " drop else 
  314.            3 > if 0 I J + FIELD2 + ! I 5 * J 80 - 6 / !PEN ."  " then then then
  315.     2 +Loop  80 +Loop ?TERMINAL if SETUP then ;
  316.     \ applies rules on amount of neigbors
  317.  
  318. : LIFE INIT Begin  COPYFIELDS  MAINLOOP Again ; 
  319. \ the main routine: life
  320.  
  321. READY        
  322. \ READY puts echo back on after calling Extended.4th !!!!!!
  323. \ SO READY MUST BE CALLED WHEN USING Extended.4th !!!!!!!
  324. LIFE         
  325. \ types LIFE to run itself
  326.  
  327. This file will run itself when dropped on Pocket Forth, but it can be
  328. made a clickable application:
  329. -make a copy of Forth
  330. -drop Life on the copy of Forth
  331. -quit Life by clicking mouse (within the window)
  332. -type:     ' life 26 +md ! save bye
  333. -rename Forth to Life
  334. -Life is your application!
  335. (Follow the same procedure for your own programs. Make sure that
  336. the word that is used is the main subroutine, and that you use a copy!)
  337.  
  338.     That's all, have fun, send all your comments to:
  339.  
  340.                 Mervyn@xs4all.nl
  341.         
  342. References:
  343. (1) L. Brodie    Starting Forth, Prentice Hall, Englewood Cliffs, 1981.
  344. (2) C. Heilman    Pocket Forth glossary and Brodie Glossary.
  345.  
  346.  
  347.  
  348. ***************************************************************************
  349.     Pocket Forth Glossary  version 0.6.3   [by Chris Heilman]
  350. ***************************************************************************
  351.  
  352. ! ( n addr -- ) say: "store"  <standard>   Store value n at the relative address, addr.
  353.  
  354. !PEN ( h v -- ) say: "store pen"   Move the graphics pen to the coordinates on the stack.
  355.  
  356. # ( dval -- dquotient ) say: "sharp"  <standard>   Convert one digit of a numeral represented by the dvalue, by dividing the value by the numeric base.  Use between "greater-than-sharp" and "sharp-less-than".
  357.  
  358. #> ( dval -- addr len ) say: "sharp-less-than"  <standard>   Leave the address and length of a string representing the formatted dvalue.  Use with #, "sharps", "sharp", "hold" and "greater-than-sharp".
  359.  
  360. #S ( dval -- 0 0 ) say: "sharps"  <standard>   Convert all of the digits of the dvalue according to the current numeric base.  Use between "greater-than-sharp" and "sharp-less-than".
  361.  
  362. ' ( -- addr ) say: "tick"  <standard>   Return the relative address of the next word from the input stream.
  363.  
  364. ( ( -- ) say: "parenthesis"  <standard>   Begin a comment.  A right parenthesis ends the comment.
  365.  
  366. (DO) ( limit index -- ) say: "paren-do" <standard>   This is the runtime word compiled into the dictionary by "do". "Paren-do" begins a loop.
  367.  
  368. * ( n1 n2 -- n1*n2 ) say: "star" or "times" <standard>   Multiply n1 by n2, and leave the 16 bit result on the stack.
  369.  
  370. */ ( n1 n2 n3 -- [n1*n2]/n3 ) say: "star-slash" <standard>   Using a 32 bit intermediate, "star-slash" puts the scaled result on the stack.
  371.  
  372. + ( n1 n2 -- n1+n2) say: "plus" <standard>   Leave the result of n1 plus n2 on the stack.
  373.  
  374. +! ( n addr -- ) say: "plus-store" <standard>   Add the value, n, to the value found at the relative address, addr.
  375.  
  376. +LOOP ( n -- ) say: "plus-loop" <standard>   Used inside of a colon definition, with "do".  Increment a loop index by n, and branch to the beginning of the loop until the index reaches the limit.  (see "loop" and "do")
  377.  
  378. +MD ( offset -- addr ) say: "plus-em-dee"   Calculate the relative address of an unnamed variable from an offset on the stack.
  379.  
  380. , ( n -- ) say: "comma" <standard>   Write and enclose the value, 'n' into the dictionary.
  381.  
  382. ,s ( -- d ) say: "comma-ess"  Stack or compile a double number literal from ASCII characters which follow ,s by exactly one space.  ,S is immediate.
  383.  
  384. ,$ ( -- ) say: "comma-dollar"   Compile a hex number from the input stream into the dictionary.   Used to compile traps and machine code.  ,$ is immediate.
  385.  
  386. - ( n1 n2 -- n1-n2 ) say: "minus" <standard>   Leave n1 minus n2 on the stack.
  387.  
  388. --> ( -- ) say: "load"  <almost standard>   Take a filename from the input stream, and load the file from the disk.  If no disk or path is specified, the default is used.  NOTE: Names may not contain spaces.
  389.  
  390. -TO ( h v -- ) say: "line to" Draw a line and move the pen to the coordinates on the stack.
  391.  
  392. -TRAILING ( addr count -- addr count' ) say: "dash-trailing" <standard>   Assuming string data on the stack, adjust the count to eliminate trailing blanks.
  393.  
  394. . ( n -- ) say: "dot" <standard>   Print the value on the stack according to the current number base.   (see "base")
  395.  
  396. ." ( -- ) say: "dot-quote" <standard>   Used inside of a colon definition to compile a routine and string data into the dictionary.  The string data follows "dot-quote" and is delimited by another quote. The string is printed at runtime.
  397.  
  398. .OK ( -- ) say: "dot-oh-kay"   Print 'ok' on the screen, indicating that the interpreter ready for input.
  399.  
  400. / ( n1 n2 -- quotient ) say: "slash" <standard>   Divide n1 by n2 and leave the 16 bit quotient on the stack.
  401.  
  402. /MOD ( n1 n2 -- quotient remainder ) say: "slash-mod" <standard>   Divide n1 by n2 and leave the 16 bit quotient and 16 bit remainder on the stack.
  403.  
  404. 0  ( -- 0 ) say: "zero" <standard>  Leave a zero on the stack.
  405.  
  406. 0< ( n -- flag ) say: "zero-less-than" <standard>   Leave a negative one on the stack if n is less than zero. Otherwise leave a zero.
  407.  
  408. 0= ( n -- flag ) say: "zero-equal" <standard>   Leave a true flag on the stack if n is zero.  Otherwise leave a zero on the stack.
  409.  
  410. 0> ( n -- flag ) say: "zero-more-than" or "zero-greater-than"  <standard>   Leave a true flag on the stack if n is greater than zero.  Otherwise leave a zero.
  411.  
  412. 1+ ( n -- n+1 ) say: "one-plus"  <standard>   Add one to the value, n on the stack.  Leave the result on the stack.
  413.  
  414. 1- ( n -- n-1 ) say: "one-minus"  <standard>   Subtract one from the value on the stack.  Leave the result on the stack.
  415.  
  416. 2! ( d addr -- ) say: "two-store"  <standard>   Store the 32 bit number, d, at the relative address, addr.
  417.  
  418. 2+ ( n -- n+2 ) say: "two-plus"  <standard>   Add two to the value on the stack, leaving the result on the stack.
  419.  
  420. 2* ( n -- n*2 ) say: "two-star" or "two-times"  <standard>   Double the value on the stack.
  421.  
  422. 2/ ( n -- n/2 ) say: "two-slash" <standard>   Halve the value on the stack, truncating to an integer.
  423.  
  424. 2>R ( d -- ) ( rstack: -- d ) say: "two to are"   Put a 32 bit number on the return stack.  Use within colon definitions.
  425.  
  426. 2@ ( addr -- d ) say:  "two at"  <standard>   Fetch a 32 bit number from relative address on the stack.
  427.  
  428. 2CONSTANT ( compile: [ d -- ] run: [ -- d ] ) <standard>   Create a 32 bit constant.
  429.  
  430. 2DROP ( d1 -- ) say: "two drop" <standard>   Drop a 32 bit number.
  431.  
  432. 2DUP ( n1 n2 -- n1 n2 n1 n2 ) say: "two-dupe" <standard>   Duplicate the top two values on the stack.
  433.  
  434. 2OVER ( d1 d2 -- d1 d2 d1 ) say: "two-over" <standard>   Duplicate the 32 bit second number to the top of the stack.
  435.  
  436. 2R> ( -- d ) ( rstack: d -- ) say: "two-are-from"   Move a 32 bit number from the return stack to the parameter stack.
  437.  
  438. 2ROT ( d1 d2 d3 -- d2 d3 d1 ) say: "two-rote" <standard>  Rotate the top three 32 bit numbers.
  439.  
  440. 2SWAP ( n1 n2 n3 n4 -- n3 n4 n1 n2 ) say: "two-swap" <standard>   Reverse the order of the top two and the second two values on the stack.
  441.  
  442. 2VARIABLE ( compile: [ -- ] run: [ -- addr ] )  <standard>   Create a 32 bit variable.  See change to "variable", below.
  443.  
  444. : ( -- ) say: "colon" <standard> "Colon" creates a new word, called a colon definition.  The token following "colon" is the name of the new word.  Non-immediate words following the name are compiled into the definition until a "semi-colon" is reached.
  445.  
  446. ; ( -- ) say: "semi-colon" <standard>  "Semi-colon" ends a colon definition and compiles a machine language return instruction. "Semi-colon" is immediate.
  447.  
  448. ;AE ( -- ) say "semi-a-e  Use "semi-a-e" to end an Apple Event definition. Pocket Forth's registers are saved and the calling registers are restored. "Semi-a-e" is an immediate word.
  449.  
  450. < ( n1 n2 -- flag ) say: "less-than" <standard>   Leave a true flag on the stack if n1 is less than n2.  Otherwise leave a zero.
  451.  
  452. <# ( -- ) say: "greater-than-sharp"  <standard>   Set up for number conversion by clearing the pad, and setting 'held' to "pad"-1.
  453.  
  454. = ( n1 n2 -- flag ) say: "equal" <standard>   Leave a true flag on the stack if n1 is the same as n2.  Otherwise leave a zero.
  455.  
  456. > ( n1 n2 -- flag ) say: "greater-than" <standard>   Leave a true flag on the stack if n1 is more than n2. Otherwise leave a zero.
  457.  
  458. >ABS ( addr16 -- daddr32 ) say: "to-abs"   Convert a relative address on the stack to a double number absolute address.   (see ">rel")
  459.  
  460. >LINK ( addr -- link.addr ) say: "to-link"  <standard>   Return the relative address of the link field of the word whose address is on the stack.
  461.  
  462. >NAME ( addr -- name.addr ) say: "to-name"  <standard>   Leave the relative address of the name field of the word whose address is on the stack.
  463.  
  464. >R ( n -- ) return stack: ( -- n ) say: "to-are" <standard>   Remove a value from the parameter stack and place it on the return stack.   (see "are-from")
  465.  
  466. >REL ( daddr32 -- addr16 ) say: "to-rel"   Convert a double number absolute address on the stack to a relative address.
  467.  
  468. ?BUTTON ( -- flag ) say: "question-button"   The flag is true if the mouse button is down, false if up.
  469.  
  470. ?DUP ( n -- n n OR n [if n=0] ) say: "question-dupe" <standard>   Duplicate the value on the stack only if it is not zero.
  471.  
  472. ?GESTALT ( d.selector -- d.response -1  or  0 ) say: "question-gestalt"  Run the system trap _Gestalt on the stacked double number.  If _Gestalt does not exist or if it exits with an error, a false flag (that is, a zero) is left on the stack.  If the call is successful, a true flag (-1) is left on the stack on top of the double number result.  Use "question-gestalt" to test computer in use.
  473.  
  474. ?STACK ( ? -- ) say: "question-stack"   Print a warning, '*?', if stack underflow has occurred.
  475.  
  476. ?TERMINAL ( -- flag ) say: "question-terminal" <standard> Leave a true flag if a key has been pressed.  In the application, events are handled by "?terminal".
  477.  
  478. @ ( addr -- n ) say: "at" (some people say: "fetch") <standard>   Leave the value found at the relative address on the stack.  The address must be even.
  479.  
  480. @MOUSE  ( -- h v ) say: "at-mouse"   Get the coordinates of the mouse pointer.
  481.  
  482. @PEN ( -- h v ) say: "at-pen"   Get the coordinates of the graphics pen pen.
  483.  
  484. A>R ( addr -- : -- dabs.addr ) say: "a-to-are"   Convert an address to absolute, and put it on the return stack. This word is used for system trap setup.  Use only within a colon definition.
  485.  
  486. ABORT ( -- )  <standard>   Stop execution, print a warning, '?' and return to the interpreter loop.
  487.  
  488. AE: ( d.type d.class -- ) say: "a-e-colon"  "Ae:" begins the definition of an Apple Event handler. D.type and d.class are the type and class signatures of the event to be handled. Follow the definition with ";ae".
  489.  
  490. AGAIN  while compiling: ( addr -- )  while executing: ( -- )  <standard>   Used to compile an unconditional branch to a relative address left by "begin".  (see "begin" and "back")  "Again" is an immediate word.
  491.  
  492. ALLOT ( n -- )  <standard>   Allocate and enclose n bytes in the dictionary.  If n is odd, n+1 bytes will be allocated.  The value of the bytes is undefined at compile time.
  493.  
  494. AND ( n1 n2 -- n1ANDn2 )  <standard>   Leave the result of n1 AND n2 on the stack.  The value is computed bitwise.
  495.  
  496. BACK while compiling: ( addr -- )  no execution behavior  <standard>   Compiles the difference between the current compilation address and the address on the stack.  "Back" is used by "again", "repeat" and "until". (also see "begin" and "while")
  497.  
  498. BASE ( -- addr )  <standard>   "Base" leaves the address of a variable containing the current number base.
  499.  
  500. BEEP ( -- )   Causes the speaker to beep at the current volume.
  501.  
  502. BEGIN ( -- )  <standard>   "Begin" starts a conditional or unconditional loop in the following manner:
  503.           BEGIN … ( -- flag ) WHILE … REPEAT,
  504.           BEGIN … ( -- flag ) UNTIL and
  505.              BEGIN … AGAIN
  506.         "Begin" is an immediate word and is used within a colon definition.  (see "while", "again", "repeat" and "until")
  507.  
  508. BYE ( -- )  "Bye" sets a variable (194 +md) that causes Pocket Forth to quit on the next trip through the event loop.
  509.  
  510. C! ( c addr -- ) say: "sea-store"  <standard>   Store the 8 bit value at the relative address (even or odd).
  511.  
  512. C@ ( addr -- c ) say: "sea-at"  <standard>   Retrieve the 8 bit value found at the address (even or odd) to the stack.
  513.  
  514. CBLK ( -- addr ) say: "sea-bee-el-kay"   Returns a relative address which contains a byte value.  If the value is 128, then the interpreter looks for input from the keyboard.  A zero value causes text to be interpreted from the file stack.
  515.  
  516. CMOVE ( addr1 addr2 n -- ) say: "sea-move" <standard>   Moves n bytes from addr1 to addr2.
  517.  
  518. COMPILE ( addr -- )   "Compile" writes a subroutine call to the relative address on the stack into the dictionary. This is not identical to Forth's standard COMPILE which takes its argument from the input stream.
  519.  
  520. CONSTANT while compiling: ( n -- )  while executing: ( -- n )  <standard>   Creates a word from the next token in the input stream, which, when executed, returns the value, n.
  521.  
  522. COUNT ( addr -- addr+1 length )  <standard>   Assuming that the relative address on the stack is the start of string data, and the byte found at addr is the strings length, the address of the start of the string characters and the string length are left on the stack.
  523.  
  524. CR ( -- ) say: "sea-are"  <standard>   "Cr" advances the cursor to the next line.  Do not confuse this word with "{cr}".
  525.  
  526. CREATE while compiling: ( -- ) while executing: ( -- addr )  <standard>   Create builds a word from the next token in the input stream.  When the new word is executed, it returns the relative address of the cell following the words entry.
  527.  
  528. CSTATE ( -- addr ) say: "sea-state"   Returns the relative address of a byte which is zero if the interpreter is not in 'compiling' mode and 128 if it is.
  529.  
  530. D+ ( n1 n2  n3 n4 -- n1+n3 n2+n4 ) say: "dee-plus"  <standard>   Adds the top two double numbers and leaves the double number sum on the stack.
  531.  
  532. D. ( d -- ) say: "dee-dot"  <standard>   Print the dvalue on the stack according to the current number base.
  533.  
  534. D>F ( d -- f ) <floating> say: "dee-to-eff" Convert a double number on the stack to a floating point number.
  535.  
  536. DABS ( dval -- |dval| ) say: "dabs"  <standard>   Return the absolute value of the dvalue on the top of the stack.
  537.  
  538. DECIMAL ( -- )  <standard>   Sets the current number base to ten.
  539.  
  540. DEPTH ( -- n )  <standard> Return the number of 16 bit entries on the stack.
  541.  
  542. DL! ( n1 n2 daddr32 -- ) say: "dee-el-store"   Store a 32 bit value at an absolute 32 bit address.
  543.  
  544. DL@ ( daddr32 -- n1 n2 ) say: "dee-el-at"   Get the 32 bit value from the 32 bit absolute address on the stack.
  545.  
  546. DLITERAL  compiling: ( d -- )  executing: ( -- d )  <standard>   "Dliteral" compiles a double number from the stack. When a word containing a dliteral is executed, the number is pushed to the stack.
  547.  
  548. DNEGATE ( d -- -d ) say: "dee-negate"  <standard>  Negate the 32 bit value on the stack.
  549.  
  550. DO ( -- )  <standard>   Compile the word "paren-do" to begin an indexed loop.  The 16 bit index is kept on the return stack, and can be accessed with r.  Use with "loop" or "+loop". "Do" is an immediate word to be used within a colon definition.  (see "paren-do", "loop" and "+loop")
  551.  
  552. DOES>  while compiling: ( -- ) while executing: ( addr -- ) say: "does"  <standard>  "Does>" is used in the definition of a defining word, following "create" to define the run-time behavior of the defined word.
  553.  
  554. DROP ( n1 n2 -- n1 )  <standard>   Remove the value on the top of the stack.
  555.  
  556. DUP ( n -- n n ) say: "dupe"  <standard>   Duplicate the value on the top of the stack.
  557.  
  558. ELSE while compiling: ( addr -- addr )  while executing: ( -- )  <standard>   Used optionally between "if" and "then" in a conditional forward branch.  "Else" is an immediate word and is used within a colon definition.
  559.  
  560. EMIT ( c -- )  <standard>   Print the ASCII character represented by the value of a number on the stack.
  561.  
  562. EXECUTE ( addr -- )  <standard>   "Execute" causes the routine whose relative address is on the stack to happen.
  563.  
  564. EXIT ( -- )  <standard>   "Exit" drops an absolute address from the return stack and executes a machine language return instruction, terminating the current routine.
  565.  
  566. EXPECT ( addr count -- )  <standard>   Waits for 'count' number of characters to be typed, storing the characters, in order, at the relative address, addr.  If more characters are typed, they are echoed to the screen, but not saved. A blank character and a zero byte are appended to the characters.  Events are handled normally during "expect".
  567.  
  568. F! ( f addr -- ) <floating> say: "eff-store" Store the floating point number, f, at address, addr.
  569.  
  570. F* ( f1 f2 -- f1*f2 ) <floating> say: "eff-times" Multiply f1 by f2 returning the product to the stack.
  571.  
  572. F+ ( f1 f2 -- f1+f2 ) <floating> say: "eff-plus" Add f1 to f2 returning the sum.
  573.  
  574. F, ( f -- ) <floating> say: "eff-comma" Enclose a floating point number from the stack to the dictionary.
  575.  
  576. F- ( f1 f2 -- f1-f2 ) <floating> say: "eff-minus" Subtract f2 from f1.
  577.  
  578. F. ( f -- ) <floating> say: "eff-dot" Output a floating point number from the stack. Infinities and NAN codes are supported. See "sci" and "fix".
  579.  
  580. F/ ( f1 f2 -- f1/f2 ) <floating> say: "eff-slash' divide f1 by f2.
  581.  
  582. F>D ( f -- d ) <floating> say: "eff-to-dee" Convert a floating point number on the stack to a double number.
  583.  
  584. F@ ( addr -- f ) <floating> say: "eff-at" Fetch the floating point number from an address in memory.
  585.  
  586. FATN ( f -- atn[f] ) <floating> say: "eff-ay-tee-en" Return the arctangent, in radians, of a floating point number. (1 radian = 57.2957795131 degrees)
  587.  
  588. FCOMPARE ( f1 f2 -- f1 f2 flag ) <floating> say: "eff-compare" A non-destructive comparison, returns a flag that depends on the relative values of f1 and f2.  If f1>f2 the flag is +1, if f1<f2 the flag is -1.  If f1=f2 exactly, the flag is zero.  Notice that f1 and f2 are unchanged, and left on the stack.
  589.  
  590. FCOS ( f -- cos[f] ) <floating> say: "eff-cos" Return the cosine of a floating point angle expressed in radians. (1 radian = 57.2957795131 degrees)
  591.  
  592. FDROP ( f -- ) <floating> say: "eff-drop" Remove the top floating point value from the top of the stack.
  593.  
  594. FDUP ( f -- f  f ) <floating> say: "eff-dup" Duplicate the floating point value on the top of the stack.
  595.  
  596. FEXP ( f -- e^f ) <floating> say: "eff-eksp" Return the value of Euler's number raised to the power of a floating point number. (e = 2.71828182846 )
  597.  
  598. FILL ( addr count char -- )  <standard>   Places 'count' characters of 'char' at the relative address, 'addr'.
  599.  
  600. FINT ( f -- int[f] ) <floating> say "eff-int" Return the whole number part of a floating point number.
  601.  
  602. FIX ( n -- ) <floating> Set floating point output to decimal fractions with n digits to the right of the decimal point. See "sci" and "f.".
  603.  
  604. FLITERAL ( comp: f -- | exec: -- f ) <floating> say: "eff-literal" Compile the code to push the value of a floating point number at runtime. Floating point literals are twenty (20) bytes in length. If a number is used more than once it is more efficient to use a constant; see "fconstant".
  605.  
  606. FLN ( f1 -- ln[f1] ) <floating> say: "eff-ell-en" Return the natural logarithm of a floating point number. (base = e = 2.71828182846 )
  607.  
  608. FNUMBER ( dabs.addr -- f ) <floating> say: "eff-number" Convert a character string located at the absolute address on the stack to a floating point number. Infinities and NAN codes are supported.
  609.  
  610. FORGET ( -- )  <standard>   Searches the dictionary for the next token from the input stream.  If found, that word and all subsequent words are removed from the dictionary.
  611.  
  612. FPACK ( fn..f1 fnew m -- fn..f1 :: fm = fnew ) <floating> say: "eff-pack" Place the floating point number, fnew, into the 'm-th' position on the stack. The floating point value, fnew, and the index, m, are removed from the stack.
  613.  
  614. FPICK ( fn..f1 m|n≥m≥1 -- fn..f1 fm ) <floating> say: "eff-pick" Duplicate the 'm-th' floating point value to the top of the stack.
  615.  
  616. FREM ( f1 f2 -- rem[f1/f2] ) <floating> say: "eff-rem" Return the remainder of f1 divided by f2.
  617.  
  618. FROLL ( fn..f1 m -- fn..fm+1 fm-1..f1 fm ) <floating> say: "froll" Roll the 'm-th' floating point number to the top of the stack, shifting the numbers between position 1 and position m ten bytes up.
  619.  
  620. FSIN ( f -- sin[f] ) <floating> say: "eff-sign" Return the sine of a floating point angle expressed in radians. (1 radian = 57.2957795131 degrees)
  621.  
  622. FSQRT ( f -- sqrt[f] ) <floating> say: "eff-squirt" Return the square root of a floating point number.
  623.  
  624. FSWAP ( f1 f2 -- f2 f1 ) <floating> say: "eff-swap" Exchange the position of the two top most floating point values on the stack.
  625.  
  626. FTAN ( f -- tan[f] ) <floating> say: "eff-tan" Return the tangent of a floating point angle expressed in radians. (1 radian = 57.2957795131 degrees)
  627.  
  628. FVARIABLE ( compile: -- ) ( run: -- addr ) <floating> say: "eff-variable" Create a ten byte variable for storing floating point numbers.
  629.  
  630. F^ ( f1 f2 -- f1^f2 ) <floating> say: "eff-to-the" Return the value of f1 raised to the power of f2.
  631.  
  632. GROW ( n -- ) <DA only> Adjust the dictionary allocation by n (modulo 32K) bytes. If n is negative, the allocation is diminished.
  633.  
  634. HEADER ( -- )   "Header" builds a name and link field for a new word at "here".
  635.  
  636. HERE ( -- addr )  <standard>   "Here" is the relative address of the start of free memory.
  637.  
  638. HEX ( -- )  <standard>   "Hex" sets the current number base to sixteen.
  639.  
  640. HOLD ( c -- )  <standard>  Insert the character on the stack into the number being converted to a string.  Use between "greater-than-sharp" and "sharp-less-than".
  641.  
  642. IF ( flag -- )  <standard>   Used with "else" and "then" to branch conditionally.  A true flag causes the words following "if" and before "then" (or "else") to be executed.  "If" is an immediate word and is used within a colon definition.
  643.  
  644. ID. ( addr -- ) say: "eye-dee-dot"  <standard>   Print the name of the word whose address is on the stack. Undefined characters are represented by an ellipsis.
  645.  
  646. IMMEDIATE ( -- )  <standard>   "Immediate" is used after a definition, to flag the word as 'immediate' so that is it will execute within a colon definition, rather than being compiled into the definition.  "Immediate" sets bit seven of the name length byte of the last word defined.
  647.  
  648. INTERPRET ( -- ) <standard>   Begin interpreting the contents of the input buffer.
  649.  
  650. KEY ( -- n )  <standard>   Waits for a character to be typed, echoes the character to the screen, advances the cursor and returns the ASCII code on the stack.  Events are handled during the wait.
  651.  
  652. L! ( n daddr32 -- ) say: "el-store"   Store the value of n at the absolute address on the stack.
  653.  
  654. L@ ( daddr32 -- n ) say: "lat" or "el-at"   Retrieve the value found at the absolute address on the stack.
  655.  
  656. LATEST ( -- name.addr )  <standard>   Return the name address of the last word defined.  Latest is used by "search" to find the end of the dictionary.
  657.  
  658. LEAVE ( -- )  <standard>   Causes a premature exit from a "do", "loop" (or "+loop") construct by setting the loop index equal to the loop limit.  Use only within a definite loop structure.
  659.  
  660. LITERAL compiling: ( n -- )  executing: ( -- n )  <standard>   "Literal" compiles a number from the stack to the dictionary.  When a word containing a literal is executed, "literal" pushes the number onto the stack.
  661.  
  662. LOOP compiling: ( addr -- )  executing: ( -- ) <standard>   "Loop" is an immediate word used to terminate a "do" … "loop" construction, in a colon definition.  Branch to the beginning of the loop if the index is less than the limit.  (see "+loop" and "do")
  663.  
  664. M/MOD ( numer32 denom16 -- rem16 quot32 ) say: "em-slash-mod"  <standard>   Divide a double number by a single number leaving a single remainder and a double quotient.
  665.  
  666. MACRO ( -- ) A word is flagged as a macro definition by following the word's definition with the word "macro".  Macro definitions compile their code field inline rather than compiling a subroutine call.  "Macro" sets bit six of the name length byte of the last word defined.  (see "mcompile" and "immediate" )
  667.  
  668. MAX ( n1 n2 -- n )  <standard>   Returns the larger of the two top numbers on the stack.
  669.  
  670. MCOMPILE ( addr -- ) "Mcompile" writes the code field found at the address on the stack.  An RTS instruction signals the end of the routine and compilation stops.  "Mcompile" compiles any word's code field.
  671.  
  672. MIN ( n1 n2 -- n )  <standard>   Returns the smaller of the top two numbers on the stack.
  673.  
  674. MOD ( n1 n2 -- remainder ) say: "mod"  <standard>   Returns the remainder (but not the quotient) of 'n1' divided by 'n2'.
  675.  
  676. MON ( -- )   Causes a monitor such as TMON or MacsBug to activate via the  _Debugger trap. Execution will continue upon exit from the monitor.
  677.  
  678. NEGATE ( n -- -n )  <standard>   Leave the result of zero minus n on the stack.
  679.  
  680. NULL ( -- )   This is a no operation word.
  681.  
  682. NUMBER ( addr -- n t  OR  f )  <standard>   "Number" attempts to convert the string at addr to a value according to the current number base.  If the conversion is successful (that is, if all characters are numerals) the value and a true flag are left on the stack.  Failure leaves only a false flag on the stack.  Unlike FORTH's NUMBER, "number" does not convert double length numbers.
  683.  
  684. OPEN ( -- ) "Open" displays the standard file dialog that allows you to select a file to be interpreted.  Unlike "-->", this does not require the path to be specified.  (see "load next file")
  685.  
  686. OR ( n1 n2 -- n1ORn2 )  <standard>   Leave the result of n1 OR n1 on the stack.  The value is computed bitwise.
  687.  
  688. OVER ( n1 n2 -- n1 n2 n1 )  <standard>   "Over" duplicates the second number on the stack to the top of the stack.
  689.  
  690. PAD ( -- addr )  <standard>   Leave the address of a scratch pad for numeric conversion.  The pad is used downward in memory.  The address of "pad" is 40 bytes beyond "here".
  691.  
  692. PAGE ( -- )  <standard>   "Page" is from the days of mechanical Teletype terminals but is still used.  It clears the window and moves the cursor to the upper left hand corner.
  693.  
  694. PMODE ( mode -- ) say: "pea-mode"   Set the drawing transfer mode of the pen.
  695.  
  696. QUIT ( -- )  <standard>   "Quit" stops executing and returns to the input loop with no message. (see "abort")
  697.  
  698. R ( -- n ) say: "are"  <standard>   "Are" puts the top 16 bit number of the return stack onto the (parameter) stack. The return stack is unaffected.  During the execution of a definite loop ("do" … "loop") the index is kept on the top of the return stack.  "Are" is used to retrieve the value of the index within these loops. (see "to-are", "are-from", "do", "loop" and "plus-loop")
  699.  
  700. R0@ ( -- dabs.addr ) say: "are-naught-at"   Return the absolute address of the bottom of the return stack.
  701.  
  702. R> ( -- n )  return stack: ( n -- ) say: "are-from"  <standard>   "Are-from" gets a number off the return stack and puts it on the parameter stack.  (see "to-are" and "are")
  703.  
  704. REPEAT while compiling: ( addr1 addr2 -- )  while executing: ( -- )  <standard>   "Repeat" is an immediate word, used within a colon definition to terminate a "begin" …"while", … "repeat" indefinite loop.  At runtime "repeat" branches unconditionally to the word following "begin" (at addr1).  (see "begin" and "while")
  705.  
  706. ROOM ( -- bytes ) "Room" leaves the bytes of headroom above "here" on the stack.  Addresses beyond the headroom should not be written to, even if they are addressable, because they may be used by the system.
  707.  
  708. ROT ( n1 n2 n3 -- n2 n3 n1 ) say: "rote"  <standard>   "Rot" brings the third stack item to the top of the stack.
  709.  
  710. RP@ ( -- dabs.addr ) say: "are-pea-at"  Return the absolute address of the top of the return stack.
  711.  
  712. S0@ ( -- dabs.addr ) say: "ess-naught-at"  Return the absolute address of the bottom of the parameter stack.
  713.  
  714. S>D ( n -- d ) say: "ess-to-dee"   Make a single number on the stack into a double number using sign extension.
  715.  
  716. SAVE ( -- )   "Save" writes the dictionary to the disk.  All pertinent data, such as headroom size, the values of variables, etc. are also saved.
  717.  
  718. SCI ( n -- ) <floating> say: "sigh" Set floating point output to scientific notation with n significant digits. See 'fix' and 'f.'.
  719.  
  720. SEARCH ( addr -- addr t OR f )   "Search" looks for the next token from the input stream in the dictionary, starting with the word whose name address is on the stack.  If found, its address and a true flag (minus one) are returned. If the search fails, a false flag (zero) is left on the stack.
  721.  
  722. SIGN ( n d -- d )  <standard>   If the single number is negative, place a negative sign into the conversion "pad".  Use between "greater-than-sharp" and "sharp-less-than".
  723.  
  724. SP@ ( -- dabs.addr ) say: "ess-pea-at" <standard>  Return the absolute address of the top of the parameter stack before the address is put on it.
  725.  
  726. SPACE ( -- ) <standard>   "Space" prints a space character.
  727.  
  728. SWAP ( n1 n2 -- n2 n1 )  <standard>   "Swap" exchanges the top two numbers on the stack.
  729.  
  730. TASK ( -- )   "Task" is a no operation word which marks the end of the dictionary.  The added part of the dictionary can be removed by executing:  FORGET TASK    : TASK ;
  731.  
  732. THEN while compiling: ( addr -- )  while executing: ( -- )  <standard>   "Then" is an immediate word which terminates an "if", ("else"), "then" construction within a colon definition. (see "if" and "then")
  733.  
  734. TIB ( -- addr ) say: "tib" (rhymes with rib)  <standard>   "Tib" returns the relative address of the terminal input buffer. The buffer is an 82 byte data area below the dictionary.  The input stream usually points to a byte within "tib".
  735.  
  736. TOKEN ( -- )   "Token" moves the next word from the input stream to "here", the end of the dictionary.
  737.  
  738. TYPE ( addr n -- ) <standard>   "Type" prints n number of characters from memory starting at the relative address, addr.  For best results addr should contain at least n ASCII characters.
  739.  
  740. U. ( n -- ) say: "you-dot"  <standard>   Print the value of n in the current numeric base as an unsigned number.
  741.  
  742. U* ( n1 n2 -- d[n1*n2] ) say: "you-star"  <standard>   "You-star" multiplies two unsigned 16 bit numbers from the stack and leaves a double number product on the stack.
  743.  
  744. UNTIL ( flag -- )  <standard>   "Unitl" is an immediate word used with in a colon definition after "begin" to conditionally terminate an indefinite loop.  If flag is true execution passes to the next word.  If false it branches back to the word following "begin".   (see "begin" and "back")
  745.  
  746. UPPER ( addr -- ) Given a string's address on the stack, "upper" converts lower case to upper case.  The first byte must contain the length of the string.
  747.  
  748. VARIABLE compiling: ( -- ) executing: ( -- addr )  <standard>   "Variable" creates a word from the next word in the input stream, and reserves one cell (two bytes) of data.  When the new word is executed, it leaves the relative address of the data cell on the stack.   Words created with "variable" are four byte macros.
  749.  
  750. WARM ( -- ) <standard> "Warm" restarts the Pocket Forth application as if it had been rebooted, except changes to the dictionary are kept.
  751.  
  752. WHAZAT ( -- ) say: "what-is-that"   "Whazat" prints the current token from the input stream, and executes "abort", if the current token was not found in the dictionary.
  753.  
  754. WHILE ( flag -- )  <standard>   "While" is an immediate word used within a colon definition, between "begin" and "repeat" to control an indefinite loop with an exit in the middle.  If the flag is true, the words after "while" and before "repeat" are executed, if the flag is false, execution jumps to the word following "repeat". (see "begin" and "repeat".)
  755.  
  756. WORD ( c -- )  <standard>   "Word" moves the next token, delimited by the character on the stack, from the input stream  to "here", the end of the dictionary.
  757.  
  758. WORDS ( -- )  <standard>   "Words" prints all of the words in the dictionary.
  759.  
  760. XOR ( n1 n2 -- ) <standard> say: "zor" or "eks-or"   Leave the result of a bitwise exclusive or of n1 and n2 on the stack.
  761.  
  762. [ ( -- ) say: "left-bracket"  <standard>   "Left-bracket" sets the interpreter into immediate mode.  Words following "left-bracket" are executed rather than compiled.  "Left-bracket" is an immediate word.
  763.  
  764. [COMPILE] ( -- ) say: "bracket-compile"  <standard>   "Bracket-compile" is an immediate word used within a colon definition to compile the following immediate word from the input stream into the current definition.
  765.  
  766. \ ( -- ) say "back slash"  <standard>   "Back slash" causes the rest of the line to be ignored. Used for commenting. "Back slash" is an immediate word.
  767.  
  768. ] ( -- ) say: "right-bracket"  <standard>   "Right-bracket" puts the interpreter into compile mode so that subsequent non-immediate words will be compiled to the dictionary.  "Right-bracket" is an immediate word.
  769.  
  770. "{cr}" ( -- ) say: ""   When the token consisting of an ascii 13 is executed, the return stack is reset, and the input sequence is restarted.  This is an immediate word.  Do not confuse this word with "cr".
  771.  
  772. "{null}" ( -- ) say: "" <standard>   This is an alias for "{cr}" to assure that "expect"ed text, which is terminated by a null (zero byte), and pasted text are treated the same.  This is an immediate word.
  773.  
  774.  
  775.  
  776.